<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>

<head>
	<base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>支付宝配置</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="static/templet/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="static/templet/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="static/templet/css/animate.min.css" rel="stylesheet">
    <link href="static/templet/css/style.min862f.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                    <div class="form-horizontal">
                        	<input type="hidden" id="id" name="id" value="${user.id }">
                        	<div class="hr-line-dashed"></div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">账号</label>

                                <div class="col-sm-10">
                                    <input type="text" id="userName" disabled name="userName" value="${user.userName }" class="form-control">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                          
                            <div class="form-group">
                                <label class="col-sm-2 control-label">联系人</label>

                                <div class="col-sm-10">
                                    <input type="text" id="petName" name="petName" value="${user.petName }" class="form-control">
                                </div>
                            </div>                          
							<div class="hr-line-dashed"></div>		
							
							<div class="form-group">
                                <label class="col-sm-2 control-label">手机号</label>

                                <div class="col-sm-10">
                                    <input type="text" id="phone" name="phone" value="${user.phone }" class="form-control">
                                </div>
                            </div>                          
							<div class="hr-line-dashed"></div>
							<div class="form-group">
                                <label class="col-sm-2 control-label">邮箱</label>

                                <div class="col-sm-10">
                                    <input type="text" id="email" name="email" value="${user.email }" class="form-control">
                                </div>
                            </div>
							<div class="hr-line-dashed"></div>
							
							<div class="form-group">
								<label class="col-sm-2 control-label">性别</label>
								<div class="col-sm-10">
									<div class="radio i-checks">
                                        <label>
                                            <input type="radio" <c:if test="${user.sex == '01' }">checked="checked"</c:if> value="01" name="sex"> <i></i> 男</label>
                                        <label>
                                            <input type="radio" <c:if test="${user.sex == '00' }">checked="checked"</c:if> value="00" name="sex"> <i></i> 女</label>
                                        <label>
                                            <input type="radio" <c:if test="${user.sex == '02' }">checked="checked"</c:if> value="02" name="sex"> <i></i> 保密</label>    
                                    </div>
								</div>
							</div>
							<div class="hr-line-dashed"></div>
							
							<div class="form-group">
                                <label class="col-sm-2 control-label">余额</label>

                                <div class="col-sm-10">
                                    <input type="text" disabled id="email" name="email" value="${user.balance }" class="form-control">
                                </div>
                            </div>
							<div class="hr-line-dashed"></div>
							<c:if test="${user.price1 gt 0}">
							<div class="form-group">
                                <label class="col-sm-2 control-label">特殊关键词价格</label>

                                <div class="col-sm-10">
                                    <input type="text" disabled  value="${user.price1 }" class="form-control">
                                </div>
                            </div>
							<div class="hr-line-dashed"></div>
							</c:if>
							<c:if test="${user.price2 gt 0}">
							<div class="form-group">
                                <label class="col-sm-2 control-label">普通关键词价格</label>

                                <div class="col-sm-10">
                                    <input type="text" disabled value="${user.price2 }" class="form-control">
                                </div>
                            </div>
							<div class="hr-line-dashed"></div>
							</c:if>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" onclick="save()" type="button">保存</button>
                                 </div>
                            </div>
                       </div>     
                    </div>
                </div>
            </div>
        </div>
    </div>

    
    <script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
    <script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="static/templet/js/content.min.js?v=1.0.0"></script>
	<script src="static/templet/js/iframe.min.js"></script>
	<script src="static/templet/js/plugins/layer/layer.min.js"></script>
    <script src="static/templet/js/plugins/iCheck/icheck.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    	$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})
    	
    });
    	function cancel(){
    		iframe.close(0);
    	}
    
		function save(){
			var load = layer.load(1, {
		        shade: [0.1,'#fff']
		    });
			var id = $.trim($("#id").val());
			if(id == ''){
				layer.msg('用户不存在', {icon: 1});
				layer.close(load);
				return;
			}
			
			var petName = $.trim($("#petName").val())
			if(petName == ''){
				layer.msg('请输入姓名', {icon: 1});
				layer.close(load);
				return;
			}
			
			var phone = $.trim($("#phone").val())
			if(phone == ''){
				layer.msg('请输入手机号', {icon: 1});
				layer.close(load);
				return;
			}
			
			var email = $.trim($("#email").val())
			if(email == ''){
				layer.msg('请输入邮箱', {icon: 1});
				layer.close(load);
				return;
			}
			var sex = $("input[name='sex']:checked").val();
			if(sex == ''){
				layer.msg('请选择性别', {icon: 1});
				layer.close(load);
				return;
			}
			
			$.post('user/save',{id:id,petName:petName,phone:phone,email:email,sex:sex}, function(data, status){
				if(status == 'success'){
					var result = data.result;
					var state = result.state;
					layer.close(load);
					if(state == 1){
						layer.msg('保存成功', {icon: 1});
					}else{
						layer.msg(result.message, {icon: 1});
					}
				}
			})
		}
		
    </script>
</body>

</html>